package get;

import java.io.IOException;
import java.net.URLEncoder;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class test3 {
	static Document doc;
	static Elements elements = new Elements();

	public static Elements getBaiduOrganicLinks (String url) throws IOException {
        doc = Jsoup.connect(url).get();
        elements = doc.getElementsByTag("h3");
        return elements;
	}
	
	public static void main (String args[]) throws IOException {
		String baiduQueryUrl = "http://www.baidu.com/s?wd=";
		String url = baiduQueryUrl.concat(URLEncoder.encode(args[0],"utf8"));
		Elements elements = getBaiduOrganicLinks(url);
		
		for (Element el : elements) {
			System.out.println(el.getElementsByTag("a").attr("href"));
		}
	}
}

	
